package com.yjt.fresh.adpater;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yjt.fresh.R;
import com.yjt.fresh.bean.BeanCoupon;
import com.yjt.fresh.bean.BeanHomePage;
import com.yjt.fresh.bean.BeanStoreCoupon;
import com.yjt.fresh.widget.CouponView;

import java.util.List;

import butterknife.BindView;

/**
 * 优惠券中心适配器
 * Created by mcc on 2018/6/10.
 */

public class AdpRvAtyGetCoupons extends BaseQuickAdapter<BeanStoreCoupon, BaseViewHolder> {
    public AdpRvAtyGetCoupons(int layoutResId, @Nullable List<BeanStoreCoupon> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BeanStoreCoupon item) {

        TextView mTvMoney = helper.getView(R.id.tv_app_recycle_item_coupon_money);

        TextView mTvFullMoney = helper.getView(R.id.tvAppRecycleItemAtyGetCouponFullMoney);

        TextView mTvName = helper.getView(R.id.tvAppRecycleItemAtyGetCouponName);

        TextView mTvTime = helper.getView(R.id.tvAppRecycleItemAtyGetCouponTime);

        TextView mTvOperation = helper.getView(R.id.tvAppRecycleItemAtyGetCouponOperation);

        TextView mTvState = helper.getView(R.id.tvAppRecycleItemAtyGetCouponState);

        TextView tvUnit = helper.getView(R.id.tvAppRecycleItemCouponCenterUnit);
        CouponView cv = helper.getView(R.id.couponViewAppRecycleItemCouponCenter);
        if ("1".equals(item.getISGET())){

            mTvOperation.setText("去使用");
            mTvState.setVisibility(View.VISIBLE);
        }else if ("0".equals(item.getISGET())){
            mTvOperation.setText("立即领取");

            mTvState.setVisibility(View.GONE);
        }



        mTvFullMoney.setText("【满"+item.getFULL_MONEY()+"元使用】");
        mTvTime.setText(item.getSTART_DATE() +"至"+item.getEND_DATE());
        mTvName.setText(item.getTITLE());
        if ("1".equals(item.getCOUPONTYPE())){
            cv.setBackgroundResource(R.drawable.shape_ff9926_5);
            mTvOperation.setBackgroundResource(R.drawable.shape_ff9926_100);
            mTvMoney.setText(item.getREDUCE_MONEY());
            tvUnit.setVisibility(View.VISIBLE);
        }else if ("2".equals(item.getCOUPONTYPE())){
            cv.setBackgroundResource(R.drawable.shape_2696ff_5);
            mTvOperation.setBackgroundResource(R.drawable.shape_2696ff_100);
            tvUnit.setVisibility(View.GONE);
            mTvMoney.setText((Double.valueOf(item.getDISCOUNT())*10)+"折");
        }

        helper.addOnClickListener(R.id.tvAppRecycleItemAtyGetCouponOperation);
    }
}
